home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1998 March / Software of the Month Club 1998 March.iso / mac / Utilities / SoftwareFPU / SoftwareFPU Documentation / Programmer Info (.txt) < prev   
Common Ground  |  1996-04-23  |  17KB  |  127 lines

  1. Times
  2. John Neil & Associates
  3. P.O. Box 2156
  4. Cupertino, CA 95015  USA
  5. Orders:
  6. E-Mail:
  7.     Web Site:
  8. (800) 663-2943
  9. (415) 661-2944
  10. sales@jna.com
  11. http://www.jna.com
  12.  of 2 
  13. lUUUU
  14. HUUUU
  15. I$UUUU
  16. ------
  17. <<<<<<
  18. KKKKKK
  19. ZZZZZZ
  20. iiiiii
  21. xxxxxx
  22. Programmer Information
  23.     John Neil
  24. April 23, 1996
  25. What SoftwareFPU Does
  26. YSoftwareFPU is a control panel which emulates a Motorola 68881 Floating Point Unit (FPU).
  27. H\It is intended to be used in any 68020, 68030, or 68LC040 Macintosh computer without an FPU.
  28. ^It can also be used on Power Macintosh machines, since the Apple 68K emulator does not emulate
  29. _FPU instructions.  It works by patching out the F-Line exception vector of the machine with one
  30. 1that points to FPU emulation code in SoftwareFPU.
  31. /Differences Between a 68881 FPU and SoftwareFPU
  32. RThe differences between the hardware FPU and SoftwareFPU are minimal.  The current
  33. H7differences between SoftwareFPU and a hardware FPU are:
  34. /FRESTORE does not support the busy state frame.
  35. GMid-instruction exceptions are reported as post-instruction exceptions.
  36. ZIf an exception occurs in trace mode, two instructions will execute before control returns
  37. to the debugger.
  38. TCode which puts data below the stack pointer and then issues an FPU instruction will
  39. Xnot work.  This is of course a no-no since data below the stack pointer can be clobbered
  40. by interrupt routines as well.
  41. OSome emulated FPU instructions may produce slightly different results than on a
  42. hardware FPU.
  43. ZYIn addition, on PowerPC machines in 64-bit accuracy mode the following differences exist:
  44. UThe rounding precision in the FPU Mode Control Byte is ignored.  All calculations are
  45. Pperformed as if double-precision rounding was selected in the Mode Control Byte.
  46. SFor performance reasons, the PowerPC emulator cannot emulate address and bus errors
  47. Xproperly.  If an FPU instruction causes an address or bus error, the emulator will break
  48. Pinto MacsBug at a location inside the emulator, rather than at the offending FPU
  49. instruction.
  50. Z<The current list of known application incompatibilities are:
  51. IAny program which replaces the F-line exception vector will not work with
  52. RSoftwareFPU.  A typical example is a source-level debugger in a development system
  53. Mlike MPW or THINK C/Symantec C++.  SoftwareFPU 3.0 provides a new facility so
  54. Times
  55. John Neil & Associates
  56. P.O. Box 2156
  57. Cupertino, CA 95015  USA
  58. Orders:
  59. E-Mail:
  60.     Web Site:
  61. (800) 663-2943
  62. (415) 661-2944
  63. sales@jna.com
  64. http://www.jna.com
  65.  of 2 
  66. gXapplications like this can detect whether SoftwareFPU is installed, to determine whether
  67. Bor not the F-Line exception vector should be replaced (see below).
  68. QA bug in the MPW 3.1 nan() function means that any program calling nan() will not
  69. Swork.  Because of this, the MPW functions atan2(), asin(), and acos() will not work
  70. Twhen they try to  produce QNANs.  Also, fscanf will not read in NANs correctly.  The
  71. bug has been fixed in MPW 3.2.
  72. MCode which assumes that calls to SANE affect the FPU will  not work.  The MPW
  73. [functions sinh() and cosh() may produce incorrect results in the exception status register,
  74. *as the library code makes this assumption.
  75. SCode that depends on 68882 or 68040 FPU stack frames or instructions will not work.
  76. FSoftwareFPU currently only emulates a 68881 FPU, even on 68LC040 CPUs.
  77. VApplications that depend upon a particular FPU should verify the type of FPU installed
  78.     with the 
  79. Courier
  80. gestaltFPUType
  81.  Gestalt selector.
  82. Performance
  83. _Because of the overhead in emulating all the intricacies of the FPU, executing FPU instructions
  84. HRthrough SoftwareFPU is slower than calling SANE.  SoftwareFPU is aware of existing
  85. [applications that can switch between hardware or software floating-point (such as Microsoft
  86. SExcel), and does not report the presence of an FPU, so they will not slow down with
  87. bSoftwareFPU installed.  However, if you are writing a new application with this functionality, you
  88. \should check whether SoftwareFPU is installed using the new facility in SoftwareFPU 3.0 (see
  89. 0below) before selecting hardware floating point.
  90. %Detecting the Presence of SoftwareFPU
  91. YSoftwareFPU adds a new Gestalt selector when it is installed in the system.  To determine
  92. HIwhether SoftwareFPU is installed, simply make the following Gestalt call:
  93. long response;
  94. $result = Gestalt(
  95. , &response);
  96. If the result of the call is 
  97. noErr
  98. ;, then SoftwareFPU is installed, and the 68881 FPU reported
  99. by the 
  100. gestaltFPUType
  101. )TD selector is an emulated FPU.  The value returned in the response is
  102. H9private to John Neil & Associates, and should be ignored.
  103. 68LC040 CPU Chip Bug
  104. MThe 68LC040 chip bug mentioned in the user documentation is that with certain
  105. HXinstructions streams, pending CPU writes to memory never arrive when an F-Line exception
  106. ^occurs.  Most Macintosh applications are not affected by the bug, since an F-Line exception is
  107. Vnormally a fatal error.   However, software that depends on F-Line exceptions, such as
  108. WSoftwareFPU, will not work properly.  There is no known work-around for the bug once an
  109. Zexception has occurred (the only possible work-around that SoftwareFPU could use).  At the
  110. dapplication level, putting a NOP in front of every F-Line instruction will eliminate the problem, at
  111. [the expense of reducing performance on machines with hardware FPUs.  Despite this bug, some
  112. [FPU applications still work with SoftwareFPU on 68LC040 machines, because their instruction
  113. Ystreams do not trigger the bug.  For more information on the bug, please contact Motorola
  114. Semiconductor Inc.
  115. *6(@4
  116. =8 >+'
  117. /    .#+
  118.  Dt    p
  119.     temp.0001
  120. John M. Neil
  121. John M. Neil
  122. Microsoft Word
  123. Times
  124. Courier
  125. rPREC
  126. ~PRVS
  127.